/*
 * IE Alert! jQuery plugin
 * version 1
 * author: David Nemes http://nmsdvid.com
 * http://nmsdvid.com/iealert/
 */

(function($){
	$("#goon").live("click", function(){
		$("#ie-alert-overlay").hide();
		$("#ie-alert-panel").hide();
	});
	function initialize($obj, support, title, text){
		var panel = "<span>"+ title +"</span>"
			+ "<p> "+ text +"</p>"
			+ "<div class='browser'>"
			+ "<ul>"
			+ "<li><a class='chrome' href='https://www.google.com/chrome/' target='_blank'></a></li>"
			+ "<li><a class='opera' href='http://se.360.cn/' target='_blank'></a></li>"
			+ "<li><a class='ie9' href='http://windows.microsoft.com/en-US/internet-explorer/downloads/ie/' target='_blank'></a></li>"
			+ "<li><a class='safari' href='http://ie.sogou.com/' target='_blank'></a></li>"
			+ "<li><a class='firefox' href='http://browser.qq.com/?adtag=SEM1' target='_blank'></a></li>"
			+ "<ul>"
			+ "</div>";

		var overlay = $("<div id='ie-alert-overlay'></div>");
		var iepanel = $("<div id='ie-alert-panel'>"+ panel +"</div>");

		var docHeight = $(document).height();

		overlay.css("height", docHeight + "px");
		if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion .split(";")[1].replace(/[ ]/g,"")=="MSIE6.0")
		{
			$obj.prepend(iepanel);
			$obj.prepend(overlay);

		}
		else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion .split(";")[1].replace(/[ ]/g,"")=="MSIE7.0")
		{
			$obj.prepend(iepanel);
			$obj.prepend(overlay);

		}
		else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion .split(";")[1].replace(/[ ]/g,"")=="MSIE8.0")
		{
			$obj.prepend(iepanel);
			$obj.prepend(overlay);

		}
		else if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion .split(";")[1].replace(/[ ]/g,"")=="MSIE9.0")
		{
			$obj.prepend(iepanel);
			$obj.prepend(overlay);
		}

	}; //end initialize function


	$.fn.iealert = function(options){
		var defaults = {
			support: "ie9",  // ie8 (ie6,ie7,ie8), ie7 (ie6,ie7), ie6 (ie6)
			title: "您使用的浏览器版本过低", // title text
			text: "为了看到我们网站最好的体验效果,我们建议您升级到最新版本的Internet Explorer或选择其他主流浏览器。您可以下载以下主流浏览器：<br /><br /><h1 id='goon' style='font-size:20px;cursor:pointer;'>>>>\u7EE7\u7EED\u8BBF\u95EE</h1>"
		};


		var option = $.extend(defaults, options);
		return this.each(function(){
			if ( $.browser.msie ) {
				var $this = $(this);
				initialize($this, option.support, option.title, option.text);
			} //if ie
		});
	};
})(jQuery);
